define(['text!js/templates/breadCrumbsTmpl.html'],function(BreadCrumbsTmpl) {
    var initialize = function(){
        breadcrumbRender(BreadCrumbsTmpl);
    };
    return {
        initialize: initialize
    };
});

function breadcrumbRender(BreadCrumbsTmpl){
    var BreadCrumb = Backbone.Model.extend({
            defaults:{
                name:""
            }
        }
    );
    var BreadCrumbCollection = Backbone.Collection.extend({
        model:BreadCrumb
    });

    var BreadCrumbCollectionView = Backbone.View.extend({
        el:$('.breadcrumb')[0],
        initialize:function () {
            breadCrumbsViews = [];
        },

        render:function () {
            var list = "";
            var compiled_template = _.template(BreadCrumbsTmpl);
            this.el.innerHTML = compiled_template({items:this.collection.toJSON()});
        }
    });

    var BreadCrumbView = Backbone.View.extend({
        render:function () {
            var compiled_template = _.template(BreadCrumbsTmpl);
            this.el.innerHTML = compiled_template({name:this.model.toJSON().name, className:'active'});
            return this;
        }
    });

    var breadCrumbs = new BreadCrumbCollection();
    breadCrumbs.add({
        name:"Best",
        link:1
    });
    breadCrumbs.add({
        name:"item",
        link:2
    });

    var brView = new BreadCrumbCollectionView();
    brView.collection = breadCrumbs;
    brView.render();
}